package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.feign.order.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class PayController {
    @Autowired
    OrderFeignClient orderFeignClient;

    @GetMapping("/pay.html")
    public String payPage(@RequestParam("orderId") Long orderId,
                          Model model){
        //远程调用订单数据
        System.out.println(orderId);
        model.addAttribute("orderInfo",orderFeignClient.getOrderInfoById(orderId).getData());

        return "payment/pay";
    }

    @GetMapping("/pay/success.html")
    public String paySuccess(){
        //不能在这个界面被访问的情况下修改订单状态，建议使用异步通知进行。
        return "payment/success";
    }
}
